<?xml version="1.0" encoding="UTF-8"?>
 <grammar xmlns="http://relaxng.org/ns/structure/1.0">

  <start>
   <element name="library">
    <ref name="library-content"/>
   </element>
  </start>
  
  <define name="library-content">
   <oneOrMore>
    <element name="book">
     <ref name="book-content"/>
    </element>
   </oneOrMore>
  </define>
  
  <define name="book-content">
   <attribute name="id"/>
   <attribute name="available"/>
   <element name="isbn">
    <ref name="isbn-content"/>
   </element>
   <element name="title">
    <ref name="title-content"/>
   </element>
   <oneOrMore>
    <element name="author">
     <ref name="author-content"/>
    </element>
   </oneOrMore>
   <zeroOrMore>
    <element name="character">
     <ref name="character-content"/>
    </element>
   </zeroOrMore>
  </define>
  
  <define name="isbn-content">
   <text/>
  </define>
  
  <define name="name-content">
   <text/>
  </define>
  
  <define name="born-content">
   <text/>
  </define>
  
  <define name="died-content">
   <text/>
  </define>
  
  <define name="qualification-content">
   <text/>
  </define>
  
  <define name="title-content">
   <attribute name="xml:lang"/>
   <text/>
  </define>
  
  <define name="author-content">
   <attribute name="id"/>
   <element name="name">
    <ref name="name-content"/>
   </element>
   <optional>
    <element name="born">
     <ref name="born-content"/>
    </element>
   </optional>
   <optional>
    <element name="died">
     <ref name="died-content"/>
    </element>
   </optional>
  </define>

  <define name="character-content">
   <attribute name="id"/>
   <element name="name">
    <ref name="name-content"/>
   </element>
   <optional>
    <element name="born">
     <ref name="born-content"/>
    </element>
   </optional>
   <element name="qualification">
    <ref name="qualification"/>
   </element>
  </define>

 </grammar>
